

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="Description" content="scikit-learn: machine learning in Python">

  
  <title>Contributing &mdash; scikit-learn 0.22 documentation</title>
  
  <link rel="canonical" href="http://scikit-learn.org/stable/developers/contributing.html" />

  
  <link rel="shortcut icon" href="../_static/favicon.ico"/>
  

  <link rel="stylesheet" href="../_static/css/vendor/bootstrap.min.css" type="text/css" />
  <link rel="stylesheet" href="../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script> 
</head>
<body>
<nav id="navbar" class="sk-docs-navbar navbar navbar-expand-md navbar-light bg-light py-0">
  <div class="container-fluid sk-docs-container px-0">
      <a class="navbar-brand py-0" href="../index.html">
        <img
          class="sk-brand-img"
          src="../_static/scikit-learn-logo-small.png"
          alt="logo"/>
      </a>
    <button
      id="sk-navbar-toggler"
      class="navbar-toggler"
      type="button"
      data-toggle="collapse"
      data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent"
      aria-expanded="false"
      aria-label="Toggle navigation"
    >
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="sk-navbar-collapse collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../install.html">Install</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../user_guide.html">User Guide</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../modules/classes.html">API</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../auto_examples/index.html">Examples</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../getting_started.html">Getting Started</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../tutorial/index.html">Tutorial</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../glossary.html">Glossary</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="index.html">Development</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../faq.html">FAQ</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../related_projects.html">Related packages</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../roadmap.html">Roadmap</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../about.html">About us</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
        </li>
        <li class="nav-item dropdown nav-more-item-dropdown">
          <a class="sk-nav-link nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">More</a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdown">
              <a class="sk-nav-dropdown-item dropdown-item" href="../getting_started.html">Getting Started</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../tutorial/index.html">Tutorial</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../glossary.html">Glossary</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="index.html">Development</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../faq.html">FAQ</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../related_projects.html">Related packages</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../roadmap.html">Roadmap</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../about.html">About us</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
          </div>
        </li>
      </ul>
      <div id="searchbox" role="search">
          <div class="searchformwrapper">
          <form class="search" action="../search.html" method="get">
            <input class="sk-search-text-input" type="text" name="q" aria-labelledby="searchlabel" />
            <input class="sk-search-text-btn" type="submit" value="Go" />
          </form>
          </div>
      </div>
    </div>
  </div>
</nav>
<div class="d-flex" id="sk-doc-wrapper">
    <input type="checkbox" name="sk-toggle-checkbox" id="sk-toggle-checkbox">
    <label id="sk-sidemenu-toggle" class="sk-btn-toggle-toc btn sk-btn-primary" for="sk-toggle-checkbox">Toggle Menu</label>
    <div id="sk-sidebar-wrapper" class="border-right">
      <div class="sk-sidebar-toc-wrapper">
        <div class="sk-sidebar-toc-logo">
          <a href="../index.html">
            <img
              class="sk-brand-img"
              src="../_static/scikit-learn-logo-small.png"
              alt="logo"/>
          </a>
        </div>
        <div class="btn-group w-100 mb-2" role="group" aria-label="rellinks">
            <a href="index.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="Developer’s Guide">Prev</a><a href="index.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="Developer’s Guide">Up</a>
            <a href="develop.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="Developing scikit-learn estimators">Next</a>
        </div>
        <div class="alert alert-danger p-1 mb-2" role="alert">
          <p class="text-center mb-0">
          <strong>scikit-learn 0.22</strong><br/>
          <a href="http://scikit-learn.org/dev/versions.html">Other versions</a>
          </p>
        </div>
        <div class="alert alert-warning p-1 mb-2" role="alert">
          <p class="text-center mb-0">
            Please <a class="font-weight-bold" href="../about.html#citing-scikit-learn"><string>cite us</string></a> if you use the software.
          </p>
        </div>
          <div class="sk-sidebar-toc">
            <ul>
<li><a class="reference internal" href="#">Contributing</a><ul>
<li><a class="reference internal" href="#ways-to-contribute">Ways to contribute</a></li>
<li><a class="reference internal" href="#submitting-a-bug-report-or-a-feature-request">Submitting a bug report or a feature request</a><ul>
<li><a class="reference internal" href="#how-to-make-a-good-bug-report">How to make a good bug report</a></li>
</ul>
</li>
<li><a class="reference internal" href="#contributing-code">Contributing code</a><ul>
<li><a class="reference internal" href="#how-to-contribute">How to contribute</a></li>
<li><a class="reference internal" href="#pull-request-checklist">Pull request checklist</a><ul>
<li><a class="reference internal" href="#continuous-integration-ci">Continuous Integration (CI)</a></li>
<li><a class="reference internal" href="#stalled-pull-requests">Stalled pull requests</a></li>
</ul>
</li>
<li><a class="reference internal" href="#issues-for-new-contributors">Issues for New Contributors</a></li>
</ul>
</li>
<li><a class="reference internal" href="#documentation">Documentation</a><ul>
<li><a class="reference internal" href="#building-the-documentation">Building the documentation</a></li>
<li><a class="reference internal" href="#guidelines-for-writing-documentation">Guidelines for writing documentation</a></li>
<li><a class="reference internal" href="#generated-documentation-on-circleci">Generated documentation on CircleCI</a></li>
</ul>
</li>
<li><a class="reference internal" href="#testing-and-improving-test-coverage">Testing and improving test coverage</a><ul>
<li><a class="reference internal" href="#writing-matplotlib-related-tests">Writing matplotlib related tests</a></li>
<li><a class="reference internal" href="#workflow-to-improve-test-coverage">Workflow to improve test coverage</a></li>
</ul>
</li>
<li><a class="reference internal" href="#issue-tracker-tags">Issue Tracker Tags</a></li>
<li><a class="reference internal" href="#maintaining-backwards-compatibility">Maintaining backwards compatibility</a><ul>
<li><a class="reference internal" href="#deprecation">Deprecation</a></li>
<li><a class="reference internal" href="#change-the-default-value-of-a-parameter">Change the default value of a parameter</a></li>
</ul>
</li>
<li><a class="reference internal" href="#code-review-guidelines">Code Review Guidelines</a></li>
<li><a class="reference internal" href="#reading-the-existing-code-base">Reading the existing code base</a></li>
</ul>
</li>
</ul>

          </div>
      </div>
    </div>
    <div id="sk-page-content-wrapper">
      <div class="sk-page-content container-fluid body px-md-3" role="main">
        
  <div class="section" id="contributing">
<span id="id1"></span><h1>Contributing<a class="headerlink" href="#contributing" title="Permalink to this headline">¶</a></h1>
<p>This project is a community effort, and everyone is welcome to
contribute.</p>
<p>The project is hosted on <a class="reference external" href="https://github.com/scikit-learn/scikit-learn">https://github.com/scikit-learn/scikit-learn</a></p>
<p>The decision making process and governance structure of scikit-learn is laid
out in the governance document: <a class="reference internal" href="../governance.html#governance"><span class="std std-ref">Scikit-learn governance and decision-making</span></a>.</p>
<p>Scikit-learn is somewhat <a class="reference internal" href="../faq.html#selectiveness"><span class="std std-ref">selective</span></a> when it comes to
adding new algorithms, and the best way to contribute and to help the project
is to start working on known issues.
See <a class="reference internal" href="#new-contributors"><span class="std std-ref">Issues for New Contributors</span></a> to get started.</p>
<div class="topic">
<p class="topic-title"><strong>Our community, our values</strong></p>
<p>We are a community based on openness and friendly, didactic,
discussions.</p>
<p>We aspire to treat everybody equally, and value their contributions.</p>
<p>Decisions are made based on technical merit and consensus.</p>
<p>Code is not the only way to help the project. Reviewing pull
requests, answering questions to help others on mailing lists or
issues, organizing and teaching tutorials, working on the website,
improving the documentation, are all priceless contributions.</p>
<p>We abide by the principles of openness, respect, and consideration of
others of the Python Software Foundation:
<a class="reference external" href="https://www.python.org/psf/codeofconduct/">https://www.python.org/psf/codeofconduct/</a></p>
</div>
<p>In case you experience issues using this package, do not hesitate to submit a
ticket to the
<a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues">GitHub issue tracker</a>. You are also
welcome to post feature requests or pull requests.</p>
<div class="section" id="ways-to-contribute">
<h2>Ways to contribute<a class="headerlink" href="#ways-to-contribute" title="Permalink to this headline">¶</a></h2>
<p>There are many ways to contribute to scikit-learn, with the most common ones
being contribution of code or documentation to the project. Improving the
documentation is no less important than improving the library itself.  If you
find a typo in the documentation, or have made improvements, do not hesitate to
send an email to the mailing list or preferably submit a GitHub pull request.
Full documentation can be found under the doc/ directory.</p>
<p>But there are many other ways to help. In particular answering queries on the
<a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues">issue tracker</a>,
investigating bugs, and <a class="reference internal" href="#code-review"><span class="std std-ref">reviewing other developers’ pull requests</span></a> are very valuable contributions that decrease the burden on the
project maintainers.</p>
<p>Another way to contribute is to report issues you’re facing, and give a “thumbs
up” on issues that others reported and that are relevant to you.  It also helps
us if you spread the word: reference the project from your blog and articles,
link to it from your website, or simply star to say “I use it”:</p>
<p>In case a contribution/issue involves changes to the API principles
or changes to dependencies or supported versions, it must be backed by a
<a class="reference internal" href="../governance.html#slep"><span class="std std-ref">Enhancement proposals (SLEPs)</span></a>, where a SLEP must be submitted as a pull-request to
<a class="reference external" href="https://scikit-learn-enhancement-proposals.readthedocs.io">enhancement proposals</a>
using the <a class="reference external" href="https://scikit-learn-enhancement-proposals.readthedocs.io/en/latest/slep_template.html">SLEP template</a>
and follows the decision-making process outlined in <a class="reference internal" href="../governance.html#governance"><span class="std std-ref">Scikit-learn governance and decision-making</span></a>.</p>
<a class="github-button" href="https://github.com/scikit-learn/scikit-learn"
data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star
scikit-learn/scikit-learn on GitHub">Star</a>
<script async defer src="https://buttons.github.io/buttons.js"></script><div class="topic">
<p class="topic-title">Contributing to related projects</p>
<p>Scikit-learn thrives in an ecosystem of several related projects, which also
may have relevant issues to work on, including smaller projects such as:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/search?q=org%3Ascikit-learn-contrib+is%3Aissue+is%3Aopen+sort%3Aupdated-desc&amp;type=Issues">scikit-learn-contrib</a></p></li>
<li><p><a class="reference external" href="https://github.com/joblib/joblib/issues">joblib</a></p></li>
<li><p><a class="reference external" href="https://github.com/sphinx-gallery/sphinx-gallery/issues">sphinx-gallery</a></p></li>
<li><p><a class="reference external" href="https://github.com/numpy/numpydoc/issues">numpydoc</a></p></li>
<li><p><a class="reference external" href="https://github.com/renatopp/liac-arff">liac-arff</a></p></li>
</ul>
<p>and larger projects:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/numpy/numpy/issues">numpy</a></p></li>
<li><p><a class="reference external" href="https://github.com/scipy/scipy/issues">scipy</a></p></li>
<li><p><a class="reference external" href="https://github.com/matplotlib/matplotlib/issues">matplotlib</a></p></li>
<li><p>and so on.</p></li>
</ul>
<p>Look for issues marked “help wanted” or similar.
Helping these projects may help Scikit-learn too.
See also <a class="reference internal" href="../related_projects.html#related-projects"><span class="std std-ref">Related Projects</span></a>.</p>
</div>
</div>
<div class="section" id="submitting-a-bug-report-or-a-feature-request">
<h2>Submitting a bug report or a feature request<a class="headerlink" href="#submitting-a-bug-report-or-a-feature-request" title="Permalink to this headline">¶</a></h2>
<p>We use GitHub issues to track all bugs and feature requests; feel free to open
an issue if you have found a bug or wish to see a feature implemented.</p>
<p>In case you experience issues using this package, do not hesitate to submit a
ticket to the
<a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues">Bug Tracker</a>. You are
also welcome to post feature requests or pull requests.</p>
<p>It is recommended to check that your issue complies with the
following rules before submitting:</p>
<ul class="simple">
<li><p>Verify that your issue is not being currently addressed by other
<a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues?q=">issues</a>
or <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/pulls?q=">pull requests</a>.</p></li>
<li><p>If you are submitting an algorithm or feature request, please verify that
the algorithm fulfills our
<a class="reference external" href="http://scikit-learn.org/stable/faq.html#what-are-the-inclusion-criteria-for-new-algorithms">new algorithm requirements</a>.</p></li>
<li><p>If you are submitting a bug report, we strongly encourage you to follow the guidelines in
<a class="reference internal" href="#filing-bugs"><span class="std std-ref">How to make a good bug report</span></a>.</p></li>
</ul>
<div class="section" id="how-to-make-a-good-bug-report">
<span id="filing-bugs"></span><h3>How to make a good bug report<a class="headerlink" href="#how-to-make-a-good-bug-report" title="Permalink to this headline">¶</a></h3>
<p>When you submit an issue to <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues">Github</a>, please do your best to
follow these guidelines! This will make it a lot easier to provide you with good
feedback:</p>
<ul>
<li><p>The ideal bug report contains a <strong>short reproducible code snippet</strong>, this way
anyone can try to reproduce the bug easily (see <a class="reference external" href="https://stackoverflow.com/help/mcve">this</a> for more details). If your snippet is
longer than around 50 lines, please link to a <a class="reference external" href="https://gist.github.com">gist</a> or a github repo.</p></li>
<li><p>If not feasible to include a reproducible snippet, please be specific about
what <strong>estimators and/or functions are involved and the shape of the data</strong>.</p></li>
<li><p>If an exception is raised, please <strong>provide the full traceback</strong>.</p></li>
<li><p>Please include your <strong>operating system type and version number</strong>, as well as
your <strong>Python, scikit-learn, numpy, and scipy versions</strong>. This information
can be found by running the following code snippet:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">sklearn</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sklearn</span><span class="o">.</span><span class="n">show_versions</span><span class="p">()</span>  
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This utility function is only available in scikit-learn v0.20+.
For previous versions, one has to explicitly run:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">platform</span><span class="p">;</span> <span class="nb">print</span><span class="p">(</span><span class="n">platform</span><span class="o">.</span><span class="n">platform</span><span class="p">())</span>
<span class="kn">import</span> <span class="nn">sys</span><span class="p">;</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Python&quot;</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">version</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">numpy</span><span class="p">;</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;NumPy&quot;</span><span class="p">,</span> <span class="n">numpy</span><span class="o">.</span><span class="n">__version__</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">scipy</span><span class="p">;</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;SciPy&quot;</span><span class="p">,</span> <span class="n">scipy</span><span class="o">.</span><span class="n">__version__</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">sklearn</span><span class="p">;</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Scikit-Learn&quot;</span><span class="p">,</span> <span class="n">sklearn</span><span class="o">.</span><span class="n">__version__</span><span class="p">)</span>
</pre></div>
</div>
</div>
</li>
<li><p>Please ensure all <strong>code snippets and error messages are formatted in
appropriate code blocks</strong>.  See <a class="reference external" href="https://help.github.com/articles/creating-and-highlighting-code-blocks">Creating and highlighting code blocks</a>
for more details.</p></li>
</ul>
</div>
</div>
<div class="section" id="contributing-code">
<h2>Contributing code<a class="headerlink" href="#contributing-code" title="Permalink to this headline">¶</a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>To avoid duplicating work, it is highly advised that you search through the
<a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues">issue tracker</a> and
the <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/pulls">PR list</a>.
If in doubt about duplicated work, or if you want to work on a non-trivial
feature, it’s recommended to first open an issue in
the <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues">issue tracker</a>
to get some feedbacks from core developers.</p>
</div>
<div class="section" id="how-to-contribute">
<h3>How to contribute<a class="headerlink" href="#how-to-contribute" title="Permalink to this headline">¶</a></h3>
<p>The preferred way to contribute to scikit-learn is to fork the <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/">main
repository</a> on GitHub,
then submit a “pull request” (PR).</p>
<p>In the first few steps, we explain how to locally install scikit-learn, and
how to set up your git repository:</p>
<ol class="arabic">
<li><p><a class="reference external" href="https://github.com/join">Create an account</a> on
GitHub if you do not already have one.</p></li>
<li><p>Fork the <a class="reference external" href="https://github.com/scikit-learn/scikit-learn">project repository</a>: click on the ‘Fork’
button near the top of the page. This creates a copy of the code under your
account on the GitHub user account. For more details on how to fork a
repository see <a class="reference external" href="https://help.github.com/articles/fork-a-repo/">this guide</a>.</p></li>
<li><p>Clone your fork of the scikit-learn repo from your GitHub account to your
local disk:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git clone git@github.com:YourLogin/scikit-learn.git
$ cd scikit-learn
</pre></div>
</div>
</li>
<li><p>Install the development dependencies:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pip install cython pytest pytest-cov flake8
</pre></div>
</div>
</li>
<li><p>Install scikit-learn in editable mode:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pip install --editable .
</pre></div>
</div>
<p>for more details about advanced installation, see the
<a class="reference internal" href="advanced_installation.html#install-bleeding-edge"><span class="std std-ref">Building from source</span></a> section.</p>
</li>
<li><p>Add the <code class="docutils literal notranslate"><span class="pre">upstream</span></code> remote. This saves a reference to the main
scikit-learn repository, which you can use to keep your repository
synchronized with the latest changes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git remote add upstream https://github.com/scikit-learn/scikit-learn.git
</pre></div>
</div>
</li>
</ol>
<p>You should now have a working installation of scikit-learn, and your git
repository properly configured. The next steps now describe the process of
modifying code and submitting a PR:</p>
<ol class="arabic" start="7">
<li><p>Synchronize your master branch with the upstream master branch:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git checkout master
$ git pull upstream master
</pre></div>
</div>
</li>
<li><p>Create a feature branch to hold your development changes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git checkout -b my_feature
</pre></div>
</div>
<p>and start making changes. Always use a feature branch. It’s good
practice to never work on the <code class="docutils literal notranslate"><span class="pre">master</span></code> branch!</p>
</li>
<li><p>Develop the feature on your feature branch on your computer, using Git to
do the version control. When you’re done editing, add changed files using
<code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">add</span></code> and then <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">commit</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git add modified_files
$ git commit
</pre></div>
</div>
<p>to record your changes in Git, then push the changes to your GitHub
account with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git push -u origin my-feature
</pre></div>
</div>
</li>
<li><p>Follow <a class="reference external" href="https://help.github.com/articles/creating-a-pull-request-from-a-fork">these</a>
instructions to create a pull request from your fork. This will send an
email to the committers. You may want to consider sending an email to the
mailing list for more visibility.</p></li>
</ol>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you are modifying a Cython module, you have to re-run step 5 after modifications
and before testing them.</p>
</div>
<p>It is often helpful to keep your local feature branch synchronized with the
latest changes of the main scikit-learn repository:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git fetch upstream
$ git merge upstream/master
</pre></div>
</div>
<p>Subsequently, you might need to solve the conflicts. You can refer to the
<a class="reference external" href="https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/">Git documentation related to resolving merge conflict using the command
line</a>.</p>
<div class="topic">
<p class="topic-title">Learning git:</p>
<p>The <a class="reference external" href="https://git-scm.com/documentation">Git documentation</a> and
<a class="reference external" href="http://try.github.io">http://try.github.io</a> are excellent resources to get started with git,
and understanding all of the commands shown here.</p>
</div>
</div>
<div class="section" id="pull-request-checklist">
<span id="pr-checklist"></span><h3>Pull request checklist<a class="headerlink" href="#pull-request-checklist" title="Permalink to this headline">¶</a></h3>
<p>Before a PR can be merged, it needs to be approved by two core developers.
Please prefix the title of your pull request with <code class="docutils literal notranslate"><span class="pre">[MRG]</span></code> if the
contribution is complete and should be subjected to a detailed review. An
incomplete contribution – where you expect to do more work before receiving
a full review – should be prefixed <code class="docutils literal notranslate"><span class="pre">[WIP]</span></code> (to indicate a work in
progress) and changed to <code class="docutils literal notranslate"><span class="pre">[MRG]</span></code> when it matures. WIPs may be useful to:
indicate you are working on something to avoid duplicated work, request
broad review of functionality or API, or seek collaborators. WIPs often
benefit from the inclusion of a <a class="reference external" href="https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments">task list</a> in
the PR description.</p>
<p>In order to ease the reviewing process, we recommend that your contribution
complies with the following rules before marking a PR as <code class="docutils literal notranslate"><span class="pre">[MRG]</span></code>. The
<strong>bolded</strong> ones are especially important:</p>
<ol class="arabic">
<li><p><strong>Give your pull request a helpful title</strong> that summarises what your
contribution does. This title will often become the commit message once
merged so it should summarise your contribution for posterity. In some
cases “Fix &lt;ISSUE TITLE&gt;” is enough. “Fix #&lt;ISSUE NUMBER&gt;” is never a
good title.</p></li>
<li><p><strong>Make sure your code passes the tests</strong>. The whole test suite can be run
with <code class="docutils literal notranslate"><span class="pre">pytest</span></code>, but it is usually not recommended since it takes a long
time. It is often enough to only run the test related to your changes:
for example, if you changed something in
<code class="docutils literal notranslate"><span class="pre">sklearn/linear_model/logistic.py</span></code>, running the following commands will
usually be enough:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">pytest</span> <span class="pre">sklearn/linear_model/logistic.py</span></code> to make sure the doctest
examples are correct</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pytest</span> <span class="pre">sklearn/linear_model/tests/test_logistic.py</span></code> to run the tests
specific to the file</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pytest</span> <span class="pre">sklearn/linear_model</span></code> to test the whole
<a class="reference internal" href="../modules/classes.html#module-sklearn.linear_model" title="sklearn.linear_model"><code class="xref py py-mod docutils literal notranslate"><span class="pre">linear_model</span></code></a> module</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pytest</span> <span class="pre">doc/modules/linear_model.rst</span></code> to make sure the user guide
examples are correct.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pytest</span> <span class="pre">sklearn/tests/test_common.py</span> <span class="pre">-k</span> <span class="pre">LogisticRegression</span></code> to run all our
estimator checks (specifically for <code class="docutils literal notranslate"><span class="pre">LogisticRegression</span></code>, if that’s the
estimator you changed).</p></li>
</ul>
<p>There may be other failing tests, but they will be caught by the CI so
you don’t need to run the whole test suite locally. For guidelines on how
to use <code class="docutils literal notranslate"><span class="pre">pytest</span></code> efficiently, see the <a class="reference internal" href="tips.html#pytest-tips"><span class="std std-ref">Useful pytest aliases and flags</span></a>.</p>
</li>
<li><p><strong>Make sure your code is properly commented and documented</strong>, and <strong>make
sure the documentation renders properly</strong>. To build the documentation, please
refer to our <a class="reference internal" href="#contribute-documentation"><span class="std std-ref">Documentation</span></a> guidelines. The CI will also
build the docs: please refer to <a class="reference internal" href="#generated-doc-ci"><span class="std std-ref">Generated documentation on CircleCI</span></a>.</p></li>
<li><p><strong>Tests are necessary for enhancements to be
accepted</strong>. Bug-fixes or new features should be provided with
<a class="reference external" href="https://en.wikipedia.org/wiki/Non-regression_testing">non-regression tests</a>. These tests
verify the correct behavior of the fix or feature. In this manner, further
modifications on the code base are granted to be consistent with the
desired behavior. In the case of bug fixes, at the time of the PR, the
non-regression tests should fail for the code base in the master branch
and pass for the PR code.</p></li>
<li><p><strong>Make sure that your PR does not add PEP8 violations</strong>. On a Unix-like
system, you can run <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">flake8-diff</span></code>. <code class="docutils literal notranslate"><span class="pre">flake8</span> <span class="pre">path_to_file</span></code>, would work
for any system, but please avoid reformatting parts of the file that your
pull request doesn’t change, as it distracts from code review.</p></li>
<li><p>Follow the <a class="reference internal" href="develop.html#coding-guidelines"><span class="std std-ref">Coding guidelines</span></a>.</p></li>
<li><p>When applicable, use the validation tools and scripts in the
<code class="docutils literal notranslate"><span class="pre">sklearn.utils</span></code> submodule.  A list of utility routines available
for developers can be found in the <a class="reference internal" href="utilities.html#developers-utils"><span class="std std-ref">Utilities for Developers</span></a> page.</p></li>
<li><p>Often pull requests resolve one or more other issues (or pull requests).
If merging your pull request means that some other issues/PRs should
be closed, you should <a class="reference external" href="https://github.com/blog/1506-closing-issues-via-pull-requests/">use keywords to create link to them</a>
(e.g., <code class="docutils literal notranslate"><span class="pre">Fixes</span> <span class="pre">#1234</span></code>; multiple issues/PRs are allowed as long as each
one is preceded by a keyword). Upon merging, those issues/PRs will
automatically be closed by GitHub. If your pull request is simply
related to some other issues/PRs, create a link to them without using
the keywords (e.g., <code class="docutils literal notranslate"><span class="pre">See</span> <span class="pre">also</span> <span class="pre">#1234</span></code>).</p></li>
<li><p>PRs should often substantiate the change, through benchmarks of
performance and efficiency or through examples of usage. Examples also
illustrate the features and intricacies of the library to users. Have a
look at other examples in the <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/tree/master/examples">examples/</a>
directory for reference. Examples should demonstrate why the new
functionality is useful in practice and, if possible, compare it to other
methods available in scikit-learn.</p></li>
<li><p>New features often need to be illustrated with narrative documentation in
the user guide, with small code snipets. If relevant, please also add
references in the literature, with PDF links when possible.</p></li>
<li><p>The user guide should also include expected time and space complexity
of the algorithm and scalability, e.g. “this algorithm can scale to a
large number of samples &gt; 100000, but does not scale in dimensionality:
n_features is expected to be lower than 100”.</p></li>
</ol>
<p>You can also check our <a class="reference internal" href="#code-review"><span class="std std-ref">Code Review Guidelines</span></a> to get an idea of what reviewers
will expect.</p>
<p>You can check for common programming errors with the following tools:</p>
<ul>
<li><p>Code with a good unittest coverage (at least 80%, better 100%), check
with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pip install pytest pytest-cov
$ pytest --cov sklearn path/to/tests_for_package
</pre></div>
</div>
<p>see also <a class="reference internal" href="#testing-coverage"><span class="std std-ref">Testing and improving test coverage</span></a></p>
</li>
</ul>
<p>Bonus points for contributions that include a performance analysis with
a benchmark script and profiling output (please report on the mailing
list or on the GitHub issue).</p>
<p>Also check out the <a class="reference internal" href="performance.html#performance-howto"><span class="std std-ref">How to optimize for speed</span></a> guide for more details on
profiling and Cython optimizations.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The current state of the scikit-learn code base is not compliant with
all of those guidelines, but we expect that enforcing those constraints
on all new contributions will get the overall code base quality in the
right direction.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>For two very well documented and more detailed guides on development
workflow, please pay a visit to the <a class="reference external" href="https://docs.scipy.org/doc/numpy/dev/gitwash/development_workflow.html">Scipy Development Workflow</a> -
and the <a class="reference external" href="https://astropy.readthedocs.io/en/latest/development/workflow/development_workflow.html">Astropy Workflow for Developers</a>
sections.</p>
</div>
<div class="section" id="continuous-integration-ci">
<h4>Continuous Integration (CI)<a class="headerlink" href="#continuous-integration-ci" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><p>Azure pipelines are used for testing scikit-learn on Linux, Mac and Windows,
with different dependencies and settings.</p></li>
<li><p>CircleCI is used to build the docs for viewing, for linting with flake8, and
for testing with PyPy on Linux</p></li>
</ul>
<p>Please note that if one of the following markers appear in the latest commit
message, the following actions are taken.</p>
<blockquote>
<div><table class="docutils align-default">
<colgroup>
<col style="width: 21%" />
<col style="width: 79%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>Commit Message Marker</p></td>
<td><p>Action Taken by CI</p></td>
</tr>
<tr class="row-even"><td><p>[scipy-dev]</p></td>
<td><p>Add a Travis build with our dependencies (numpy, scipy, etc …) development builds</p></td>
</tr>
<tr class="row-odd"><td><p>[ci skip]</p></td>
<td><p>CI is skipped completely</p></td>
</tr>
<tr class="row-even"><td><p>[doc skip]</p></td>
<td><p>Docs are not built</p></td>
</tr>
<tr class="row-odd"><td><p>[doc quick]</p></td>
<td><p>Docs built, but excludes example gallery plots</p></td>
</tr>
<tr class="row-even"><td><p>[doc build]</p></td>
<td><p>Docs built including example gallery plots</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
</div>
<div class="section" id="stalled-pull-requests">
<h4>Stalled pull requests<a class="headerlink" href="#stalled-pull-requests" title="Permalink to this headline">¶</a></h4>
<p>As contributing a feature can be a lengthy process, some
pull requests appear inactive but unfinished. In such a case, taking
them over is a great service for the project.</p>
<p>A good etiquette to take over is:</p>
<ul>
<li><p><strong>Determine if a PR is stalled</strong></p>
<ul>
<li><p>A pull request may have the label “stalled” or “help wanted” if we
have already identified it as a candidate for other contributors.</p></li>
<li><p>To decide whether an inactive PR is stalled, ask the contributor if
she/he plans to continue working on the PR in the near future.
Failure to respond within 2 weeks with an activity that moves the PR
forward suggests that the PR is stalled and will result in tagging
that PR with “help wanted”.</p>
<p>Note that if a PR has received earlier comments on the contribution
that have had no reply in a month, it is safe to assume that the PR
is stalled and to shorten the wait time to one day.</p>
<p>After a sprint, follow-up for un-merged PRs opened during sprint will
be communicated to participants at the sprint, and those PRs will be
tagged “sprint”. PRs tagged with “sprint” can be reassigned or
declared stalled by sprint leaders.</p>
</li>
</ul>
</li>
<li><p><strong>Taking over a stalled PR</strong>: To take over a PR, it is important to
comment on the stalled PR that you are taking over and to link from the
new PR to the old one. The new PR should be created by pulling from the
old one.</p></li>
</ul>
</div>
</div>
<div class="section" id="issues-for-new-contributors">
<span id="new-contributors"></span><h3>Issues for New Contributors<a class="headerlink" href="#issues-for-new-contributors" title="Permalink to this headline">¶</a></h3>
<p>New contributors should look for the following tags when looking for issues.  We
strongly recommend that new contributors tackle “easy” issues first: this helps
the contributor become familiar with the contribution workflow, and for the core
devs to become acquainted with the contributor; besides which, we frequently
underestimate how easy an issue is to solve!</p>
<div class="topic">
<p class="topic-title">good first issue tag</p>
<p>A great way to start contributing to scikit-learn is to pick an item from
the list of <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/labels/good%20first%20issue">good first issues</a>
in the issue tracker. Resolving these issues allow you to start contributing
to the project without much prior knowledge. If you have already contributed
to scikit-learn, you should look at Easy issues instead.</p>
</div>
<div class="topic">
<p class="topic-title">Easy tag</p>
<p>If you have already contributed to scikit-learn, another great way to contribute
to scikit-learn is to pick an item from the list of <a class="reference external" href="https://github.com/scikit-learn/scikit-learn/labels/Easy">Easy issues</a> in the issue
tracker. Your assistance in this area will be greatly appreciated by the
more experienced developers as it helps free up their time to concentrate on
other issues.</p>
</div>
<div class="topic">
<p class="topic-title">help wanted tag</p>
<p>We often use the help wanted tag to mark issues regardless of difficulty. Additionally,
we use the help wanted tag to mark Pull Requests which have been abandoned
by their original contributor and are available for someone to pick up where the original
contributor left off. The list of issues with the help wanted tag can be found
<a class="reference external" href="https://github.com/scikit-learn/scikit-learn/labels/help%20wanted">here</a> .</p>
<p>Note that not all issues which need contributors will have this tag.</p>
</div>
</div>
</div>
<div class="section" id="documentation">
<span id="contribute-documentation"></span><h2>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h2>
<p>We are glad to accept any sort of documentation: function docstrings,
reStructuredText documents (like this one), tutorials, etc. reStructuredText
documents live in the source code repository under the <code class="docutils literal notranslate"><span class="pre">doc/</span></code> directory.</p>
<p>You can edit the documentation using any text editor, and then generate the
HTML output by typing <code class="docutils literal notranslate"><span class="pre">make</span></code> from the <code class="docutils literal notranslate"><span class="pre">doc/</span></code> directory. Alternatively,
<code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">html</span></code> may be used to generate the documentation <strong>with</strong> the example
gallery (which takes quite some time). The resulting HTML files will be
placed in <code class="docutils literal notranslate"><span class="pre">_build/html/stable</span></code> and are viewable in a web browser.</p>
<div class="section" id="building-the-documentation">
<h3>Building the documentation<a class="headerlink" href="#building-the-documentation" title="Permalink to this headline">¶</a></h3>
<p>First, make sure you have <a class="reference internal" href="advanced_installation.html#install-bleeding-edge"><span class="std std-ref">properly installed</span></a>
the development version.</p>
<p>Building the documentation requires installing some additional packages:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">sphinx</span> <span class="n">sphinx</span><span class="o">-</span><span class="n">gallery</span> <span class="n">numpydoc</span> <span class="n">matplotlib</span> <span class="n">Pillow</span> <span class="n">pandas</span> <span class="n">scikit</span><span class="o">-</span><span class="n">image</span> <span class="n">packaging</span>
</pre></div>
</div>
<p>To build the documentation, you need to be in the <code class="docutils literal notranslate"><span class="pre">doc</span></code> folder:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">doc</span>
</pre></div>
</div>
<p>In the vast majority of cases, you only need to generate the full web site,
without the example gallery:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">make</span>
</pre></div>
</div>
<p>The documentation will be generated in the <code class="docutils literal notranslate"><span class="pre">_build/html/stable</span></code> directory.
To also generate the example gallery you can use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">html</span>
</pre></div>
</div>
<p>This will run all the examples, which takes a while. If you only want to
generate a few examples, you can use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">EXAMPLES_PATTERN</span><span class="o">=</span><span class="n">your_regex_goes_here</span> <span class="n">make</span> <span class="n">html</span>
</pre></div>
</div>
<p>This is particularly useful if you are modifying a few examples.</p>
<p>Set the environment variable <code class="docutils literal notranslate"><span class="pre">NO_MATHJAX=1</span></code> if you intend to view
the documentation in an offline setting.</p>
<p>To build the PDF manual, run:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">latexpdf</span>
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p><strong>Sphinx version</strong></p>
<p>While we do our best to have the documentation build under as many
versions of Sphinx as possible, the different versions tend to
behave slightly differently. To get the best results, you should
use the same version as the one we used on CircleCI. Look at this
<a class="reference external" href="https://github.com/search?utf8=%E2%9C%93&amp;q=sphinx+repo%3Ascikit-learn%2Fscikit-learn+extension%3Ash+path%3Abuild_tools%2Fcircle&amp;type=Code">github search</a>
to know the exact version.</p>
</div>
</div>
<div class="section" id="guidelines-for-writing-documentation">
<h3>Guidelines for writing documentation<a class="headerlink" href="#guidelines-for-writing-documentation" title="Permalink to this headline">¶</a></h3>
<p>It is important to keep a good compromise between mathematical and algorithmic
details, and give intuition to the reader on what the algorithm does.</p>
<p>Basically, to elaborate on the above, it is best to always
start with a small paragraph with a hand-waving explanation of what the
method does to the data. Then, it is very helpful to point out why the feature is
useful and when it should be used - the latter also including “big O”
(<span class="math notranslate nohighlight">\(O\left(g\left(n\right)\right)\)</span>) complexities of the algorithm, as opposed
to just <em>rules of thumb</em>, as the latter can be very machine-dependent. If those
complexities are not available, then rules of thumb may be provided instead.</p>
<p>Secondly, a generated figure from an example (as mentioned in the previous
paragraph) should then be included to further provide some intuition.</p>
<p>Next, one or two small code examples to show its use can be added.</p>
<p>Next, any math and equations, followed by references,
can be added to further the documentation. Not starting the
documentation with the maths makes it more friendly towards
users that are just interested in what the feature will do, as
opposed to how it works “under the hood”.</p>
<p>Finally, follow the formatting rules below to make it consistently good:</p>
<ul>
<li><p>Add “See also” in docstrings for related classes/functions.</p></li>
<li><p>“See also” in docstrings should be one line per reference,
with a colon and an explanation, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">See</span> <span class="n">also</span>
<span class="o">--------</span>
<span class="n">SelectKBest</span> <span class="p">:</span> <span class="n">Select</span> <span class="n">features</span> <span class="n">based</span> <span class="n">on</span> <span class="n">the</span> <span class="n">k</span> <span class="n">highest</span> <span class="n">scores</span><span class="o">.</span>
<span class="n">SelectFpr</span> <span class="p">:</span> <span class="n">Select</span> <span class="n">features</span> <span class="n">based</span> <span class="n">on</span> <span class="n">a</span> <span class="n">false</span> <span class="n">positive</span> <span class="n">rate</span> <span class="n">test</span><span class="o">.</span>
</pre></div>
</div>
</li>
<li><p>When documenting the parameters and attributes, here is a list of some
well-formatted examples:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>n_clusters : int, default=3
    The number of clusters detected by the algorithm.

some_param : {&#39;hello&#39;, &#39;goodbye&#39;}, bool or int, default=True
    The parameter description goes here, which can be either a string
    literal (either `hello` or `goodbye`), a bool, or an int. The default
    value is True.

array_parameter : {array-like, sparse matrix, dataframe} of shape (n_samples, n_features) or (n_samples,)
    This parameter accepts data in either of the mentioned forms, with one
    of the mentioned shapes. The default value is
    `np.ones(shape=(n_samples,))`.

list_param : list of int

typed_ndarray : ndarray of shape (n_samples,), dtype=np.int32

sample_weight : array-like of shape (n_samples,), default=None
</pre></div>
</div>
</li>
</ul>
<p>In general have the following in mind:</p>
<blockquote>
<div><ol class="arabic simple">
<li><p>Use Python basic types. (<code class="docutils literal notranslate"><span class="pre">bool</span></code> instead of <code class="docutils literal notranslate"><span class="pre">boolean</span></code>)</p></li>
<li><p>Use parenthesis for defining shapes: <code class="docutils literal notranslate"><span class="pre">array-like</span> <span class="pre">of</span> <span class="pre">shape</span> <span class="pre">(n_samples,)</span></code>
or <code class="docutils literal notranslate"><span class="pre">array-like</span> <span class="pre">of</span> <span class="pre">shape</span> <span class="pre">(n_samples,</span> <span class="pre">n_features)</span></code></p></li>
<li><p>For strings with multiple options, use brackets:
<code class="docutils literal notranslate"><span class="pre">input:</span> <span class="pre">{'log',</span> <span class="pre">'squared',</span> <span class="pre">'multinomial'}</span></code></p></li>
<li><p>1D or 2D data can be a subset of
<code class="docutils literal notranslate"><span class="pre">{array-like,</span> <span class="pre">ndarray,</span> <span class="pre">sparse</span> <span class="pre">matrix,</span> <span class="pre">dataframe}</span></code>. Note that <code class="docutils literal notranslate"><span class="pre">array-like</span></code>
can also be a <code class="docutils literal notranslate"><span class="pre">list</span></code>, while <code class="docutils literal notranslate"><span class="pre">ndarray</span></code> is explicitly only a <code class="docutils literal notranslate"><span class="pre">numpy.ndarray</span></code>.</p></li>
<li><p>When specifying the data type of a list, use <code class="docutils literal notranslate"><span class="pre">of</span></code> as a delimiter:
<code class="docutils literal notranslate"><span class="pre">list</span> <span class="pre">of</span> <span class="pre">int</span></code>.</p></li>
<li><p>When specifying the dtype of an ndarray, use e.g. <code class="docutils literal notranslate"><span class="pre">dtype=np.int32</span></code>
after defining the shape:
<code class="docutils literal notranslate"><span class="pre">ndarray</span> <span class="pre">of</span> <span class="pre">shape</span> <span class="pre">(n_samples,),</span> <span class="pre">dtype=np.int32</span></code>.</p></li>
<li><p>When the default is <code class="docutils literal notranslate"><span class="pre">None</span></code>, <code class="docutils literal notranslate"><span class="pre">None</span></code> only needs to be specified at the
end with <code class="docutils literal notranslate"><span class="pre">default=None</span></code>. Be sure to include in the docstring, what it
means for the parameter or attribute to be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p></li>
</ol>
</div></blockquote>
<ul>
<li><p>For unwritten formatting rules, try to follow existing good works:</p>
<blockquote>
<div><ul class="simple">
<li><p>For “References” in docstrings, see the Silhouette Coefficient
(<a class="reference internal" href="../modules/generated/sklearn.metrics.silhouette_score.html#sklearn.metrics.silhouette_score" title="sklearn.metrics.silhouette_score"><code class="xref py py-func docutils literal notranslate"><span class="pre">sklearn.metrics.silhouette_score</span></code></a>).</p></li>
</ul>
</div></blockquote>
</li>
<li><p>When editing reStructuredText (<code class="docutils literal notranslate"><span class="pre">.rst</span></code>) files, try to keep line length under
80 characters when possible (exceptions include links and tables).</p></li>
<li><p>Before submitting you pull request check if your modifications have introduced
new sphinx warnings and try to fix them.</p></li>
</ul>
</div>
<div class="section" id="generated-documentation-on-circleci">
<span id="generated-doc-ci"></span><h3>Generated documentation on CircleCI<a class="headerlink" href="#generated-documentation-on-circleci" title="Permalink to this headline">¶</a></h3>
<p>When you change the documentation in a pull request, CircleCI automatically
builds it. To view the documentation generated by CircleCI:</p>
<ul class="simple">
<li><p>navigate to the bottom of your pull request page to see the CI
statuses. You may need to click on “Show all checks” to see all the CI
statuses.</p></li>
<li><p>click on the CircleCI status with “doc” in the title.</p></li>
<li><p>add <code class="docutils literal notranslate"><span class="pre">#artifacts</span></code> at the end of the URL. Note: you need to wait for the
CircleCI build to finish before being able to look at the artifacts.</p></li>
<li><p>once the artifacts are visible, navigate to <code class="docutils literal notranslate"><span class="pre">doc/_changed.html</span></code> to see a
list of documentation pages that are likely to be affected by your pull
request. Navigate to <code class="docutils literal notranslate"><span class="pre">doc/index.html</span></code> to see the full generated html
documentation.</p></li>
</ul>
<p>If you often need to look at the documentation generated by CircleCI, e.g. when
reviewing pull requests, you may find <a class="reference internal" href="tips.html#viewing-rendered-html-documentation"><span class="std std-ref">this tip</span></a> very handy.</p>
</div>
</div>
<div class="section" id="testing-and-improving-test-coverage">
<span id="testing-coverage"></span><h2>Testing and improving test coverage<a class="headerlink" href="#testing-and-improving-test-coverage" title="Permalink to this headline">¶</a></h2>
<p>High-quality <a class="reference external" href="https://en.wikipedia.org/wiki/Unit_testing">unit testing</a>
is a corner-stone of the scikit-learn development process. For this
purpose, we use the <a class="reference external" href="https://docs.pytest.org">pytest</a>
package. The tests are functions appropriately named, located in <code class="docutils literal notranslate"><span class="pre">tests</span></code>
subdirectories, that check the validity of the algorithms and the
different options of the code.</p>
<p>Running <code class="docutils literal notranslate"><span class="pre">pytest</span></code> in a folder will run all the tests of the corresponding
subpackages. For a more detailed <code class="docutils literal notranslate"><span class="pre">pytest</span></code> workflow, please refer to the
<a class="reference internal" href="#pr-checklist"><span class="std std-ref">Pull request checklist</span></a>.</p>
<p>We expect code coverage of new features to be at least around 90%.</p>
<div class="section" id="writing-matplotlib-related-tests">
<h3>Writing matplotlib related tests<a class="headerlink" href="#writing-matplotlib-related-tests" title="Permalink to this headline">¶</a></h3>
<p>Test fixtures ensure that a set of tests will be executing with the appropriate
initialization and cleanup. The scikit-learn test suite implements a fixture
which can be used with <code class="docutils literal notranslate"><span class="pre">matplotlib</span></code>.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">pyplot</span></code></dt><dd><p>The <code class="docutils literal notranslate"><span class="pre">pyplot</span></code> fixture should be used when a test function is dealing with
<code class="docutils literal notranslate"><span class="pre">matplotlib</span></code>. <code class="docutils literal notranslate"><span class="pre">matplotlib</span></code> is a soft dependency and is not required.
This fixture is in charge of skipping the tests if <code class="docutils literal notranslate"><span class="pre">matplotlib</span></code> is not
installed. In addition, figures created during the tests will be
automatically closed once the test function has been executed.</p>
</dd>
</dl>
<p>To use this fixture in a test function, one needs to pass it as an
argument:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">test_requiring_mpl_fixture</span><span class="p">(</span><span class="n">pyplot</span><span class="p">):</span>
    <span class="c1"># you can now safely use matplotlib</span>
</pre></div>
</div>
</div>
<div class="section" id="workflow-to-improve-test-coverage">
<h3>Workflow to improve test coverage<a class="headerlink" href="#workflow-to-improve-test-coverage" title="Permalink to this headline">¶</a></h3>
<p>To test code coverage, you need to install the <a class="reference external" href="https://pypi.org/project/coverage/">coverage</a> package in addition to pytest.</p>
<ol class="arabic simple">
<li><dl class="simple">
<dt>Run ‘make test-coverage’. The output lists for each file the line</dt><dd><p>numbers that are not tested.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>Find a low hanging fruit, looking at which lines are not tested,</dt><dd><p>write or adapt a test specifically for these lines.</p>
</dd>
</dl>
</li>
<li><p>Loop.</p></li>
</ol>
</div>
</div>
<div class="section" id="issue-tracker-tags">
<h2>Issue Tracker Tags<a class="headerlink" href="#issue-tracker-tags" title="Permalink to this headline">¶</a></h2>
<p>All issues and pull requests on the
<a class="reference external" href="https://github.com/scikit-learn/scikit-learn/issues">GitHub issue tracker</a>
should have (at least) one of the following tags:</p>
<dl class="field-list simple">
<dt class="field-odd">Bug / Crash</dt>
<dd class="field-odd"><p>Something is happening that clearly shouldn’t happen.
Wrong results as well as unexpected errors from estimators go here.</p>
</dd>
<dt class="field-even">Cleanup / Enhancement</dt>
<dd class="field-even"><p>Improving performance, usability, consistency.</p>
</dd>
<dt class="field-odd">Documentation</dt>
<dd class="field-odd"><p>Missing, incorrect or sub-standard documentations and examples.</p>
</dd>
<dt class="field-even">New Feature</dt>
<dd class="field-even"><p>Feature requests and pull requests implementing a new feature.</p>
</dd>
</dl>
<p>There are four other tags to help new contributors:</p>
<dl class="field-list simple">
<dt class="field-odd">good first issue</dt>
<dd class="field-odd"><p>This issue is ideal for a first contribution to scikit-learn. Ask for help
if the formulation is unclear. If you have already contributed to
scikit-learn, look at Easy issues instead.</p>
</dd>
<dt class="field-even">Easy</dt>
<dd class="field-even"><p>This issue can be tackled without much prior experience.</p>
</dd>
<dt class="field-odd">Moderate</dt>
<dd class="field-odd"><p>Might need some knowledge of machine learning or the package,
but is still approachable for someone new to the project.</p>
</dd>
<dt class="field-even">help wanted</dt>
<dd class="field-even"><p>This tag marks an issue which currently lacks a contributor or a
PR that needs another contributor to take over the work. These
issues can range in difficulty, and may not be approachable
for new contributors. Note that not all issues which need
contributors will have this tag.</p>
</dd>
</dl>
</div>
<div class="section" id="maintaining-backwards-compatibility">
<span id="backwards-compatibility"></span><h2>Maintaining backwards compatibility<a class="headerlink" href="#maintaining-backwards-compatibility" title="Permalink to this headline">¶</a></h2>
<div class="section" id="deprecation">
<span id="contributing-deprecation"></span><h3>Deprecation<a class="headerlink" href="#deprecation" title="Permalink to this headline">¶</a></h3>
<p>If any publicly accessible method, function, attribute or parameter
is renamed, we still support the old one for two releases and issue
a deprecation warning when it is called/passed/accessed.
E.g., if the function <code class="docutils literal notranslate"><span class="pre">zero_one</span></code> is renamed to <code class="docutils literal notranslate"><span class="pre">zero_one_loss</span></code>,
we add the decorator <code class="docutils literal notranslate"><span class="pre">deprecated</span></code> (from <code class="docutils literal notranslate"><span class="pre">sklearn.utils</span></code>)
to <code class="docutils literal notranslate"><span class="pre">zero_one</span></code> and call <code class="docutils literal notranslate"><span class="pre">zero_one_loss</span></code> from that function:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="n">deprecated</span>

<span class="k">def</span> <span class="nf">zero_one_loss</span><span class="p">(</span><span class="n">y_true</span><span class="p">,</span> <span class="n">y_pred</span><span class="p">,</span> <span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="c1"># actual implementation</span>
    <span class="k">pass</span>

<span class="nd">@deprecated</span><span class="p">(</span><span class="s2">&quot;Function &#39;zero_one&#39; was renamed to &#39;zero_one_loss&#39; &quot;</span>
            <span class="s2">&quot;in version 0.13 and will be removed in release 0.15. &quot;</span>
            <span class="s2">&quot;Default behavior is changed from &#39;normalize=False&#39; to &quot;</span>
            <span class="s2">&quot;&#39;normalize=True&#39;&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">zero_one</span><span class="p">(</span><span class="n">y_true</span><span class="p">,</span> <span class="n">y_pred</span><span class="p">,</span> <span class="n">normalize</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">zero_one_loss</span><span class="p">(</span><span class="n">y_true</span><span class="p">,</span> <span class="n">y_pred</span><span class="p">,</span> <span class="n">normalize</span><span class="p">)</span>
</pre></div>
</div>
<p>If an attribute is to be deprecated,
use the decorator <code class="docutils literal notranslate"><span class="pre">deprecated</span></code> on a property. Please note that the
<code class="docutils literal notranslate"><span class="pre">property</span></code> decorator should be placed before the <code class="docutils literal notranslate"><span class="pre">deprecated</span></code>
decorator for the docstrings to be rendered properly.
E.g., renaming an attribute <code class="docutils literal notranslate"><span class="pre">labels_</span></code> to <code class="docutils literal notranslate"><span class="pre">classes_</span></code> can be done as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@deprecated</span><span class="p">(</span><span class="s2">&quot;Attribute labels_ was deprecated in version 0.13 and &quot;</span>
            <span class="s2">&quot;will be removed in 0.15. Use &#39;classes_&#39; instead&quot;</span><span class="p">)</span>
<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">labels_</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">classes_</span>
</pre></div>
</div>
<p>If a parameter has to be deprecated, a <code class="docutils literal notranslate"><span class="pre">FutureWarning</span></code> warning
must be raised too.
In the following example, k is deprecated and renamed to n_clusters:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">warnings</span>

<span class="k">def</span> <span class="nf">example_function</span><span class="p">(</span><span class="n">n_clusters</span><span class="o">=</span><span class="mi">8</span><span class="p">,</span> <span class="n">k</span><span class="o">=</span><span class="s1">&#39;deprecated&#39;</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">k</span> <span class="o">!=</span> <span class="s1">&#39;deprecated&#39;</span><span class="p">:</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;&#39;k&#39; was renamed to n_clusters in version 0.13 and &quot;</span>
                      <span class="s2">&quot;will be removed in 0.15.&quot;</span><span class="p">,</span>
                      <span class="ne">FutureWarning</span><span class="p">)</span>
        <span class="n">n_clusters</span> <span class="o">=</span> <span class="n">k</span>
</pre></div>
</div>
<p>When the change is in a class, we validate and raise warning in <code class="docutils literal notranslate"><span class="pre">fit</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">warnings</span>

<span class="k">class</span> <span class="nc">ExampleEstimator</span><span class="p">(</span><span class="n">BaseEstimator</span><span class="p">):</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n_clusters</span><span class="o">=</span><span class="mi">8</span><span class="p">,</span> <span class="n">k</span><span class="o">=</span><span class="s1">&#39;deprecated&#39;</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">n_clusters</span> <span class="o">=</span> <span class="n">n_clusters</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">k</span> <span class="o">=</span> <span class="n">k</span>

    <span class="k">def</span> <span class="nf">fit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">k</span> <span class="o">!=</span> <span class="s1">&#39;deprecated&#39;</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;&#39;k&#39; was renamed to n_clusters in version 0.13 and &quot;</span>
                          <span class="s2">&quot;will be removed in 0.15.&quot;</span><span class="p">,</span>
                          <span class="ne">FutureWarning</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_n_clusters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">k</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_n_clusters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">n_clusters</span>
</pre></div>
</div>
<p>As in these examples, the warning message should always give both the
version in which the deprecation happened and the version in which the
old behavior will be removed. If the deprecation happened in version
0.x-dev, the message should say deprecation occurred in version 0.x and
the removal will be in 0.(x+2), so that users will have enough time to
adapt their code to the new behaviour. For example, if the deprecation happened
in version 0.18-dev, the message should say it happened in version 0.18
and the old behavior will be removed in version 0.20.</p>
<p>In addition, a deprecation note should be added in the docstring, recalling the
same information as the deprecation warning as explained above. Use the
<code class="docutils literal notranslate"><span class="pre">..</span> <span class="pre">deprecated::</span></code> directive:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>.. deprecated:: 0.13
   ``k`` was renamed to ``n_clusters`` in version 0.13 and will be removed
   in 0.15.
</pre></div>
</div>
<p>What’s more, a deprecation requires a test which ensures that the warning is
raised in relevant cases but not in other cases. The warning should be caught
in all other tests (using e.g., <code class="docutils literal notranslate"><span class="pre">&#64;pytest.mark.filterwarnings</span></code>),
and there should be no warning in the examples.</p>
</div>
<div class="section" id="change-the-default-value-of-a-parameter">
<h3>Change the default value of a parameter<a class="headerlink" href="#change-the-default-value-of-a-parameter" title="Permalink to this headline">¶</a></h3>
<p>If the default value of a parameter needs to be changed, please replace the
default value with a specific value (e.g., <code class="docutils literal notranslate"><span class="pre">warn</span></code>) and raise
<code class="docutils literal notranslate"><span class="pre">FutureWarning</span></code> when users are using the default value. In the following
example, we change the default value of <code class="docutils literal notranslate"><span class="pre">n_clusters</span></code> from 5 to 10
(current version is 0.20):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">warnings</span>

<span class="k">def</span> <span class="nf">example_function</span><span class="p">(</span><span class="n">n_clusters</span><span class="o">=</span><span class="s1">&#39;warn&#39;</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">n_clusters</span> <span class="o">==</span> <span class="s1">&#39;warn&#39;</span><span class="p">:</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;The default value of n_clusters will change from &quot;</span>
                      <span class="s2">&quot;5 to 10 in 0.22.&quot;</span><span class="p">,</span> <span class="ne">FutureWarning</span><span class="p">)</span>
        <span class="n">n_clusters</span> <span class="o">=</span> <span class="mi">5</span>
</pre></div>
</div>
<p>When the change is in a class, we validate and raise warning in <code class="docutils literal notranslate"><span class="pre">fit</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">warnings</span>

<span class="k">class</span> <span class="nc">ExampleEstimator</span><span class="p">:</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n_clusters</span><span class="o">=</span><span class="s1">&#39;warn&#39;</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">n_clusters</span> <span class="o">=</span> <span class="n">n_clusters</span>

    <span class="k">def</span> <span class="nf">fit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">n_clusters</span> <span class="o">==</span> <span class="s1">&#39;warn&#39;</span><span class="p">:</span>
          <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;The default value of n_clusters will change from &quot;</span>
                        <span class="s2">&quot;5 to 10 in 0.22.&quot;</span><span class="p">,</span> <span class="ne">FutureWarning</span><span class="p">)</span>
          <span class="bp">self</span><span class="o">.</span><span class="n">_n_clusters</span> <span class="o">=</span> <span class="mi">5</span>
</pre></div>
</div>
<p>Similar to deprecations, the warning message should always give both the
version in which the change happened and the version in which the old behavior
will be removed. The docstring needs to be updated accordingly. We need a test
which ensures that the warning is raised in relevant cases but not in other
cases. The warning should be caught in all other tests
(using e.g., <code class="docutils literal notranslate"><span class="pre">&#64;pytest.mark.filterwarnings</span></code>), and there should be no warning
in the examples.</p>
</div>
</div>
<div class="section" id="code-review-guidelines">
<span id="code-review"></span><h2>Code Review Guidelines<a class="headerlink" href="#code-review-guidelines" title="Permalink to this headline">¶</a></h2>
<p>Reviewing code contributed to the project as PRs is a crucial component of
scikit-learn development. We encourage anyone to start reviewing code of other
developers. The code review process is often highly educational for everybody
involved. This is particularly appropriate if it is a feature you would like to
use, and so can respond critically about whether the PR meets your needs. While
each pull request needs to be signed off by two core developers, you can speed
up this process by providing your feedback.</p>
<p>Here are a few important aspects that need to be covered in any code review,
from high-level questions to a more detailed check-list.</p>
<ul class="simple">
<li><p>Do we want this in the library? Is it likely to be used? Do you, as
a scikit-learn user, like the change and intend to use it? Is it in
the scope of scikit-learn? Will the cost of maintaining a new
feature be worth its benefits?</p></li>
<li><p>Is the code consistent with the API of scikit-learn? Are public
functions/classes/parameters well named and intuitively designed?</p></li>
<li><p>Are all public functions/classes and their parameters, return types, and
stored attributes named according to scikit-learn conventions and documented clearly?</p></li>
<li><p>Is any new functionality described in the user-guide and illustrated with examples?</p></li>
<li><p>Is every public function/class tested? Are a reasonable set of
parameters, their values, value types, and combinations tested? Do
the tests validate that the code is correct, i.e. doing what the
documentation says it does? If the change is a bug-fix, is a
non-regression test included? Look at <a class="reference external" href="https://jeffknupp.com/blog/2013/12/09/improve-your-python-understanding-unit-testing">this</a>
to get started with testing in Python.</p></li>
<li><p>Do the tests pass in the continuous integration build? If
appropriate, help the contributor understand why tests failed.</p></li>
<li><p>Do the tests cover every line of code (see the coverage report in the build
log)? If not, are the lines missing coverage good exceptions?</p></li>
<li><p>Is the code easy to read and low on redundancy? Should variable names be
improved for clarity or consistency? Should comments be added? Should comments
be removed as unhelpful or extraneous?</p></li>
<li><p>Could the code easily be rewritten to run much more efficiently for
relevant settings?</p></li>
<li><p>Is the code backwards compatible with previous versions? (or is a
deprecation cycle necessary?)</p></li>
<li><p>Will the new code add any dependencies on other libraries? (this is
unlikely to be accepted)</p></li>
<li><p>Does the documentation render properly (see the
<a class="reference internal" href="#contribute-documentation"><span class="std std-ref">Documentation</span></a> section for more details), and are the plots
instructive?</p></li>
</ul>
<p><a class="reference internal" href="tips.html#saved-replies"><span class="std std-ref">Standard replies for reviewing</span></a> includes some frequent comments that reviewers may make.</p>
</div>
<div class="section" id="reading-the-existing-code-base">
<h2>Reading the existing code base<a class="headerlink" href="#reading-the-existing-code-base" title="Permalink to this headline">¶</a></h2>
<p>Reading and digesting an existing code base is always a difficult exercise
that takes time and experience to master. Even though we try to write simple
code in general, understanding the code can seem overwhelming at first,
given the sheer size of the project. Here is a list of tips that may help
make this task easier and faster (in no particular order).</p>
<ul class="simple">
<li><p>Get acquainted with the <a class="reference internal" href="develop.html#api-overview"><span class="std std-ref">APIs of scikit-learn objects</span></a>: understand what <a class="reference internal" href="../glossary.html#term-fit"><span class="xref std std-term">fit</span></a>,
<a class="reference internal" href="../glossary.html#term-predict"><span class="xref std std-term">predict</span></a>, <a class="reference internal" href="../glossary.html#term-transform"><span class="xref std std-term">transform</span></a>, etc. are used for.</p></li>
<li><p>Before diving into reading the code of a function / class, go through the
docstrings first and try to get an idea of what each parameter / attribute
is doing. It may also help to stop a minute and think <em>how would I do this
myself if I had to?</em></p></li>
<li><p>The trickiest thing is often to identify which portions of the code are
relevant, and which are not. In scikit-learn <strong>a lot</strong> of input checking
is performed, especially at the beginning of the <a class="reference internal" href="../glossary.html#term-fit"><span class="xref std std-term">fit</span></a> methods.
Sometimes, only a very small portion of the code is doing the actual job.
For example looking at the <code class="docutils literal notranslate"><span class="pre">fit()</span></code> method of
<a class="reference internal" href="../modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression" title="sklearn.linear_model.LinearRegression"><code class="xref py py-class docutils literal notranslate"><span class="pre">sklearn.linear_model.LinearRegression</span></code></a>, what you’re looking for
might just be the call the <code class="docutils literal notranslate"><span class="pre">scipy.linalg.lstsq</span></code>, but it is buried into
multiple lines of input checking and the handling of different kinds of
parameters.</p></li>
<li><p>Due to the use of <a class="reference external" href="https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)">Inheritance</a>,
some methods may be implemented in parent classes. All estimators inherit
at least from <a class="reference internal" href="../modules/generated/sklearn.base.BaseEstimator.html#sklearn.base.BaseEstimator" title="sklearn.base.BaseEstimator"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseEstimator</span></code></a>, and
from a <code class="docutils literal notranslate"><span class="pre">Mixin</span></code> class (e.g. <a class="reference internal" href="../modules/generated/sklearn.base.ClassifierMixin.html#sklearn.base.ClassifierMixin" title="sklearn.base.ClassifierMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">ClassifierMixin</span></code></a>) that enables default behaviour depending
on the nature of the estimator (classifier, regressor, transformer, etc.).</p></li>
<li><p>Sometimes, reading the tests for a given function will give you an idea of
what its intended purpose is. You can use <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">grep</span></code> (see below) to find
all the tests written for a function. Most tests for a specific
function/class are placed under the <code class="docutils literal notranslate"><span class="pre">tests/</span></code> folder of the module</p></li>
<li><p>You’ll often see code looking like this:
<code class="docutils literal notranslate"><span class="pre">out</span> <span class="pre">=</span> <span class="pre">Parallel(...)(delayed(some_function)(param)</span> <span class="pre">for</span> <span class="pre">param</span> <span class="pre">in</span>
<span class="pre">some_iterable)</span></code>. This runs <code class="docutils literal notranslate"><span class="pre">some_function</span></code> in parallel using <a class="reference external" href="https://joblib.readthedocs.io/">Joblib</a>. <code class="docutils literal notranslate"><span class="pre">out</span></code> is then an iterable containing
the values returned by <code class="docutils literal notranslate"><span class="pre">some_function</span></code> for each call.</p></li>
<li><p>We use <a class="reference external" href="https://cython.org/">Cython</a> to write fast code. Cython code is
located in <code class="docutils literal notranslate"><span class="pre">.pyx</span></code> and <code class="docutils literal notranslate"><span class="pre">.pxd</span></code> files. Cython code has a more C-like
flavor: we use pointers, perform manual memory allocation, etc. Having
some minimal experience in C / C++ is pretty much mandatory here.</p></li>
<li><p>Master your tools.</p>
<ul>
<li><p>With such a big project, being efficient with your favorite editor or
IDE goes a long way towards digesting the code base. Being able to quickly
jump (or <em>peek</em>) to a function/class/attribute definition helps a lot.
So does being able to quickly see where a given name is used in a file.</p></li>
<li><p><a class="reference external" href="https://git-scm.com/book/en">git</a> also has some built-in killer
features. It is often useful to understand how a file changed over time,
using e.g. <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">blame</span></code> (<a class="reference external" href="https://git-scm.com/docs/git-blame">manual</a>). This can also be done directly
on GitHub. <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">grep</span></code> (<a class="reference external" href="https://git-scm.com/docs/git-grep#_examples">examples</a>) is also extremely
useful to see every occurrence of a pattern (e.g. a function call or a
variable) in the code base.</p></li>
</ul>
</li>
</ul>
</div>
</div>


      </div>
    <div class="container">
      <footer class="sk-content-footer">
            &copy; 2007 - 2019, scikit-learn developers (BSD License).
          <a href="../_sources/developers/contributing.rst.txt" rel="nofollow">Show this page source</a>
      </footer>
    </div>
  </div>
</div>
<script src="../_static/js/vendor/bootstrap.min.js"></script>

<script>
    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
    ga('create', 'UA-22606712-2', 'auto');
    ga('set', 'anonymizeIp', true);
    ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>


<script>
$(document).ready(function() {
    /* Add a [>>>] button on the top-right corner of code samples to hide
     * the >>> and ... prompts and the output and thus make the code
     * copyable. */
    var div = $('.highlight-python .highlight,' +
                '.highlight-python3 .highlight,' +
                '.highlight-pycon .highlight,' +
		'.highlight-default .highlight')
    var pre = div.find('pre');

    // get the styles from the current theme
    pre.parent().parent().css('position', 'relative');
    var hide_text = 'Hide prompts and outputs';
    var show_text = 'Show prompts and outputs';

    // create and add the button to all the code blocks that contain >>>
    div.each(function(index) {
        var jthis = $(this);
        if (jthis.find('.gp').length > 0) {
            var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
            jthis.prepend(button);
        }
        // tracebacks (.gt) contain bare text elements that need to be
        // wrapped in a span to work with .nextUntil() (see later)
        jthis.find('pre:has(.gt)').contents().filter(function() {
            return ((this.nodeType == 3) && (this.data.trim().length > 0));
        }).wrap('<span>');
    });

    // define the behavior of the button when it's clicked
    $('.copybutton').click(function(e){
        e.preventDefault();
        var button = $(this);
        if (button.data('hidden') === 'false') {
            // hide the code output
            button.parent().find('.go, .gp, .gt').hide();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
            button.css('text-decoration', 'line-through');
            button.attr('title', show_text);
            button.data('hidden', 'true');
        } else {
            // show the code output
            button.parent().find('.go, .gp, .gt').show();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
            button.css('text-decoration', 'none');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
        }
    });

	/*** Add permalink buttons next to glossary terms ***/
	$('dl.glossary > dt[id]').append(function() {
		return ('<a class="headerlink" href="#' +
			    this.getAttribute('id') +
			    '" title="Permalink to this term">¶</a>');
	});
  /*** Hide navbar when scrolling down ***/
  // Returns true when headerlink target matches hash in url
  (function() {
    hashTargetOnTop = function() {
        var hash = window.location.hash;
        if ( hash.length < 2 ) { return false; }

        var target = document.getElementById( hash.slice(1) );
        if ( target === null ) { return false; }

        var top = target.getBoundingClientRect().top;
        return (top < 2) && (top > -2);
    };

    // Hide navbar on load if hash target is on top
    var navBar = document.getElementById("navbar");
    var navBarToggler = document.getElementById("sk-navbar-toggler");
    var navBarHeightHidden = "-" + navBar.getBoundingClientRect().height + "px";
    var $window = $(window);

    hideNavBar = function() {
        navBar.style.top = navBarHeightHidden;
    };

    showNavBar = function() {
        navBar.style.top = "0";
    }

    if (hashTargetOnTop()) {
        hideNavBar()
    }

    var prevScrollpos = window.pageYOffset;
    hideOnScroll = function(lastScrollTop) {
        if (($window.width() < 768) && (navBarToggler.getAttribute("aria-expanded") === 'true')) {
            return;
        }
        if (lastScrollTop > 2 && (prevScrollpos <= lastScrollTop) || hashTargetOnTop()){
            hideNavBar()
        } else {
            showNavBar()
        }
        prevScrollpos = lastScrollTop;
    };

    /*** high preformance scroll event listener***/
    var raf = window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        window.oRequestAnimationFrame;
    var lastScrollTop = $window.scrollTop();

    if (raf) {
        loop();
    }

    function loop() {
        var scrollTop = $window.scrollTop();
        if (lastScrollTop === scrollTop) {
            raf(loop);
            return;
        } else {
            lastScrollTop = scrollTop;
            hideOnScroll(lastScrollTop);
            raf(loop);
        }
    }
  })();
});

</script>
    
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
    
</body>
</html>